package com.luyun.frogpay.base.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.luyun.frogpay.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述：
 *
 * @author 无人区
 * @date 2019/8/19
 */
public class RxDialogList extends RxDialog {
    private List<String> stringList = new ArrayList<>();

    private ListView dialogLv;

    private CenterDialogAdapter photoDialogAdapter;

    public RxDialogList(Context context, int themeResId) {
        super(context, themeResId);
        initView();
    }

    public RxDialogList(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
        initView();
    }

    public RxDialogList(Context context) {
        super(context);
        initView();
    }

    public RxDialogList(Context context, float alpha, int gravity) {
        super(context, alpha, gravity);
        initView();
    }

    public void setStringList(List<String> stringList){
        this.stringList.clear();
        this.stringList.addAll(stringList);
        photoDialogAdapter.notifyDataSetChanged();
    }

    public void setItemClickListener(AdapterView.OnItemClickListener listener) {
        dialogLv.setOnItemClickListener(listener);
    }

    private void initView(){
        View v = LayoutInflater.from(getContext()).inflate(
                R.layout.__picker_dialog_photo_pager, null);
        dialogLv = (ListView) v.findViewById(R.id.dialog_lv);
        photoDialogAdapter = new CenterDialogAdapter(getContext(), stringList);
        dialogLv.setAdapter(photoDialogAdapter);
    }

}
